﻿<?php
class LogAction extends BaseAction{
	var $dao;
	function _initialize(){
        parent::_initialize();
		$this->dao = D('Log');		
	}
		
	public function index(){
 		//操作日志
		$map['type']  = 'admin';//dump($map);
		$list = $this->dao->where( $map )->order('id desc')->findPage(50);
		foreach ($list['data'] as $k=>&$v){
			$v['data'] = $this->dao->_tempOne($v);
			if(empty($v['data'])){
				unset($list['data'][$k]);continue;
			}else{
				$v['info'] = empty($v['info']) ? '&nbsp;' : $v['info'];	
			}
		}

		$this->assign('logList', $list['data']);
		$this->assign('count', $list['count']);
		$this->assign('html', $list['html']); 
        		
		$this->display();
	}
	
	function doCleanFeed(){
		$type = $_POST['dataType'];
		
		switch ($type){
			case '清除30天前的日志':  $date = 30;  break;
			case '清除60天前的日志':  $date = 60;  break;
			case '清除90天前的日志':  $date = 90;  break;
			case '清除180天前的日志': $date = 180; break;
			case '清除360天前的日志': $date = 360; break;
			default: $date = -1;
		}
		
		$time = mktime(0,0,0,date('m'), date('d')-$date, date('Y'));
		
		$map['cTime'] = array('exp', "<$time");
		$res = $this->dao->where($map)->delete();		
		if($res){
			$this->success('清除成功');
		}else{
			$this->error('已经没有可清除的数据了');
		}
	}
}
?>